let username = document.querySelector("#name");//用户名
let psw = document.querySelector("#pwd");//设置密码
let password = document.querySelector("#qrpwd");//确认密码
let email = document.querySelector("#email");//企业邮箱
let nam = document.querySelector("#gsmc");//公司名称
let phone = document.querySelector("#phone");//手机号码
let code = document.querySelector("#yzm");//验证码
let registerCommitBtn = document.querySelector("#registerCommitBtn");//按钮

let user = /\w{6,50}/;
let bool ;
username.onblur = function(){
    let span = document.getElementById("namesp");
    if(this.value.length == 0){
        span.innerHTML = "用户名不能为空"
        span.style.color = "#a94442";
        username.style.borderColor = "#a94442"; 
        bool = false
    }else{
        if(user.test(this.value)){
            span.innerHTML = "支持中文、英文、数字，6-50个字符内";
            span.style.color = "#3c763d"; 
            username.style.borderColor = "#3c763d"; 
            bool = true;
        }else{
            span.innerHTML = "支持中文、英文、数字，6-50个字符内";
            span.style.color="#333"
            username.style.borderColor = "#a94442"; 
            bool = false;
        }
    }
}

let pass = /.{8,}/;
psw.onblur = function(){
    let two = document.getElementById("pwdsp");
    if(this.value.length == 0){
        two.innerHTML = "密码不能为空";
        two.style.color = "#a94442";
        psw.style.borderColor = "#a94442"; 
        bool = false
    }else{
        if(pass.test(this.value)){
            two.innerHTML = "至少8个字符，需包含字母、数字、特殊字符（特殊字符包括：!@#$%&amp;*_）";
            two.style.color = "#3c763d"; 
            psw.style.borderColor = "#3c763d"; 
            bool = true;
        }else{
            two.innerHTML = "至少8个字符，需包含字母、数字、特殊字符（特殊字符包括：!@#$%&amp;*_）";
            two.style.color = "#333"
            psw.style.borderColor = "#a94442"; 
            bool = false
        }
    }
    
}

password.onblur = function(){
    let three = document.getElementById("qrpwdsp");
    if(this.value.length == 0){
        password.style.borderColor = "#a94442"; 
        bool = false
    }else{
        let pas = psw.value;
        if(pas==(this.value)){
            password.style.borderColor = "#3c763d"; 
            bool = true;
        }else{
            password.style.borderColor = "#a94442"; 
            bool = false;
        }
    }
}

let ema = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
email.onblur = function(){
    if(this.value.length == 0){
        email.style.borderColor = "#a94442"; 
        bool = false;
    }else{
        if(ema.test(this.value)){
            email.style.borderColor = "#3c763d"; 
            bool = true;
        }else{
            email.style.borderColor = "#a94442"; 
            bool = false;
        }
    }
}

nam.onblur = function(){
    let five = document.getElementById("gsmcsp");
    
    if(this.value.length == 0){
        five.innerHTML = "公司名称不能为空";
        five.style.color = "#a94442"; 
        nam.style.borderColor = "#a94442"; 
        bool = false;
    }else{
        five.innerHTML = "营业执照或公司注册文件（国外）上公司名称。";
        five.style.color = "#3c763d"
        nam.style.borderColor = "#3c763d"; 
        bool = true;
    }
}

let number = /^1[3|4|5|7|8][0-9]{9}$/;
phone.onblur = function(){
    let span = document.getElementById("sjhsp");
    if(this.value.length == 0){
        span.style.color = "#a94442"; 
        phone.style.borderColor = "#a94442";  
        span.innerHTML = "手机号不能为空！";
        bool = false;
    }
    if(number.test(this.value)){
        span.innerHTML = "";
        bool = true;
    }else{
        span.style.color = "#a94442"; 
        phone.style.borderColor = "#a94442";  
        span.innerHTML = "手机号格式不对！";
        bool = false;
    }
    
}

let cod = /^aona$/;
code.onblur = function(){
    if(this.value.length == 0){
        code.style.borderColor = "#a94442"; 
        bool = false;
    }else{
        if(cod.test(this.value)){
            code.style.borderColor = "#3c763d"; 
            bool = true;
        }else{
            code.style.borderColor = "#a94442"; 
            bool = false;
        }
    }
}

/* registerCommitBtn.onclick = function(){
    if(bool){
        
    }else{
        alert("信息未完成，完成后提交");
    }
} */